package leetcode.L1000;

public class EX947 {
    public int removeStones(int[][] stones) {
        int n = stones.length;
        int res = 0;
        if(n==0){
            return 0;
        }
        int[] table0 = new int[10010];
        int[] table1 = new int[10010];
        for(int i = 0;i<n;i++){
            table0[stones[i][0]]++;
            table1[stones[i][1]]++;
        }
        for(int i = 0;i<n;i++){
            if(table0[stones[i][0]]>1||table1[stones[i][1]]>1){
                table0[stones[i][0]]--;
                table1[stones[i][1]]--;
                res++;
            }

        }
        return res;
    }
    public static void main(String[] args) {
        int[][] nums = {{0,1},{1,2},{1,3},{3,3},{2,3},{0,2}};
        EX947 solution = new EX947();
        int lists = solution.removeStones(nums);
        System.out.println(lists);
    }
}
